#include<iostream>
#include<string.h>
#include<ctype.h>
using namespace std;
class Solution {
public:
    string greatestLetter(string s) {
        int lower=0,upper=0;char a;
        for(int i=0;i<s.size();i++)
        {
            if(islower(s[i]))lower|=1<<(s[i]-'a');
            else if(isupper(s[i]))upper|=1<<(s[i]-'A'); 
        }
        for(int i=25;i>=0;i--)
        {
            if(lower&upper&(1<<i))
            {
                return string(1,i+'A');
            }
        }
        return "";
    }
};